function s1 = aggregate(s2,agg_length)
x2 = s2.x;
h2 = s2.h;
if mod(length(x2),agg_length)~=0
    warning('The original number of points cannot be divided by AGG_LENGTH, consider change an AGG_LENGTH');
end
x1 = x2(1:agg_length:end);
h1 = zeros(size(x1));
for i = 1:length(x1)
    h1(i) = mean(h2((i-1)*agg_length+1:i*agg_length));
end
s1 = surface1D(x1,h1);